<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf"
  xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf"
  xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options">

  <Style x:Key="MaterialDesignHeaderedContentControl" TargetType="{x:Type HeaderedContentControl}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type HeaderedContentControl}">
          <StackPanel>
            <wpf:ColorZone>
              <ContentPresenter ContentSource="Header"/>
            </wpf:ColorZone>
            <ContentPresenter/>
          </StackPanel>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignGroupBox" TargetType="{x:Type GroupBox}">
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
    <Setter Property="Padding" Value="9"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth0"/>
    <Setter Property="wpf:ColorZoneAssist.Mode" Value="PrimaryMid"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type GroupBox}">
          <Grid>
            <Border Background="{TemplateBinding Background}" BorderBrush="{Binding Path=Background, ElementName=PART_ColorZone}" BorderThickness="{TemplateBinding BorderThickness}"/>
            <DockPanel Background="{TemplateBinding Background}">
              <wpf:ColorZone
                UseLayoutRounding="True"
                x:Name="PART_ColorZone"
                DockPanel.Dock="Top"
                Padding="{TemplateBinding Padding}"
                Effect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ShadowAssist.ShadowDepth), Converter={x:Static converters:ShadowConverter.Instance}}"
                wpf:ShadowAssist.ShadowEdges="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ShadowAssist.ShadowEdges)}"
                Mode="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ColorZoneAssist.Mode)}"
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                <ContentPresenter
                  ContentSource="Header"
                  RecognizesAccessKey="False"
                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                  ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                  ContentTemplate="{TemplateBinding HeaderTemplate}"
                  ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"/>
              </wpf:ColorZone>
              <ContentPresenter
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                Margin="{TemplateBinding Padding}"
                ContentStringFormat="{TemplateBinding ContentStringFormat}"
                ContentTemplate="{TemplateBinding ContentTemplate}"
                ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
            </DockPanel>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignCardGroupBox" TargetType="{x:Type GroupBox}">
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
    <Setter Property="Padding" Value="9"/>
    <Setter Property="BorderThickness" Value="0"/>
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth0"/>
    <Setter Property="wpf:ColorZoneAssist.Mode" Value="PrimaryMid"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type GroupBox}">
          <wpf:Card VerticalAlignment="Stretch">
            <DockPanel Background="{TemplateBinding Background}">
              <wpf:ColorZone
                x:Name="PART_ColorZone"
                DockPanel.Dock="Top"
                Padding="{TemplateBinding Padding}"
                Effect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ShadowAssist.ShadowDepth), Converter={x:Static converters:ShadowConverter.Instance}}"
                Mode="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ColorZoneAssist.Mode)}">
                <ContentPresenter
                  ContentSource="Header"
                  RecognizesAccessKey="False"
                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                  TextBlock.FontFamily="{DynamicResource HeaderFontFamily}"
                  TextBlock.FontSize="15"
                  ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                  ContentTemplate="{TemplateBinding HeaderTemplate}"
                  ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"/>
              </wpf:ColorZone>
              <ContentPresenter
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                Margin="{TemplateBinding Padding}"
                ContentStringFormat="{TemplateBinding ContentStringFormat}"
                ContentTemplate="{TemplateBinding ContentTemplate}"
                ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
            </DockPanel>
          </wpf:Card>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignRaisedCardGroupBox" BasedOn="{StaticResource MaterialDesignCardGroupBox}" TargetType="{x:Type GroupBox}">
    <Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth2"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type GroupBox}">
          <Grid>
            <AdornerDecorator>
              <AdornerDecorator.CacheMode>
                  <BitmapCache EnableClearType="True" SnapsToDevicePixels="True"/>
              </AdornerDecorator.CacheMode>
              <Border x:Name="ShadowBorder"
                      Background="{DynamicResource MaterialDesignShadowBrush}"
                      CornerRadius="2"
                      Effect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ShadowAssist.ShadowDepth), Converter={x:Static converters:ShadowConverter.Instance}}">
              </Border>
            </AdornerDecorator>
            <Grid>
              <Grid.OpacityMask>
                <VisualBrush Visual="{Binding ElementName=maskCard}"/>
              </Grid.OpacityMask>
              <wpf:Card Name="maskCard" Style="{DynamicResource MaterialDesignFlatCard}" VerticalAlignment="Stretch" Background="Transparent" UniformCornerRadius="2">
                <DockPanel Background="{TemplateBinding Background}">
                  <wpf:ColorZone
                    x:Name="PART_ColorZone"
                    DockPanel.Dock="Top"
                    Padding="{TemplateBinding Padding}"
                    Background="{DynamicResource PrimaryHueMidLightBrush}"
                    Foreground="{DynamicResource PrimaryHueMidLightForegroundBrush}"
                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                    <ContentPresenter
                      ContentSource="Header"
                      RecognizesAccessKey="False"
                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                      TextBlock.FontFamily="{DynamicResource HeaderFontFamily}"
                      TextBlock.FontSize="15"
                      ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                      ContentTemplate="{TemplateBinding HeaderTemplate}"
                      ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"/>
                  </wpf:ColorZone>
                  <ContentPresenter
                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                    Margin="{TemplateBinding Padding}"
                    ContentStringFormat="{TemplateBinding ContentStringFormat}"
                    ContentTemplate="{TemplateBinding ContentTemplate}"
                    ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
                </DockPanel>
              </wpf:Card>
            </Grid>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignNoColorRaisedCardGroupBox" BasedOn="{StaticResource MaterialDesignCardGroupBox}" TargetType="{x:Type GroupBox}">
    <Setter Property="Background" Value="{DynamicResource MaterialDesignPaper}"/>
    <Setter Property="Margin" Value="0,4"/>
    <Setter Property="Padding" Value="4,2,4,4"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type GroupBox}">
          <wpf:Card Name="maskCard" Style="{DynamicResource MaterialDesignRaisedCard}" wpf:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch" Background="{TemplateBinding Background}" UniformCornerRadius="4">
            <DockPanel Margin="{TemplateBinding Padding}">
              <ContentPresenter
                ContentSource="Header"
                DockPanel.Dock="Top"
                Margin="{TemplateBinding Padding}"
                RecognizesAccessKey="False"
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                TextBlock.FontFamily="{DynamicResource HeaderFontFamily}"
                TextBlock.FontSize="14"
                ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                ContentTemplate="{TemplateBinding HeaderTemplate}"
                ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"/>
              <ContentPresenter
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                Margin="{TemplateBinding Padding}"
                ContentStringFormat="{TemplateBinding ContentStringFormat}"
                ContentTemplate="{TemplateBinding ContentTemplate}"
                ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
            </DockPanel>
          </wpf:Card>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignRoundedRaisedCardGroupBox" BasedOn="{StaticResource MaterialDesignRaisedCardGroupBox}" TargetType="{x:Type GroupBox}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type GroupBox}">
          <Grid Effect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ShadowAssist.ShadowDepth), Converter={x:Static converters:ShadowConverter.Instance}}">
            <Grid.OpacityMask>
              <VisualBrush Visual="{Binding ElementName=maskCard}"/>
            </Grid.OpacityMask>
            <wpf:Card Name="maskCard" Style="{DynamicResource MaterialDesignFlatCard}" VerticalAlignment="Stretch" Background="Transparent" UniformCornerRadius="10">
              <DockPanel Background="{TemplateBinding Background}">
                <wpf:ColorZone
                  x:Name="PART_ColorZone"
                  DockPanel.Dock="Top"
                  Padding="{TemplateBinding Padding}"
                  Background="{DynamicResource PrimaryHueMidLightBrush}"
                  Foreground="{DynamicResource PrimaryHueMidLightForegroundBrush}"
                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                  <ContentPresenter
                    ContentSource="Header"
                    RecognizesAccessKey="False"
                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                    TextBlock.FontFamily="{DynamicResource HeaderFontFamily}"
                    TextBlock.FontSize="15"
                    ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                    ContentTemplate="{TemplateBinding HeaderTemplate}"
                    ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"/>
                </wpf:ColorZone>
                <ContentPresenter
                  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                  Margin="{TemplateBinding Padding}"
                  ContentStringFormat="{TemplateBinding ContentStringFormat}"
                  ContentTemplate="{TemplateBinding ContentTemplate}"
                  ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
              </DockPanel>
            </wpf:Card>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignWizardGroupBox" TargetType="{x:Type GroupBox}">
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
    <Setter Property="BorderThickness" Value="0"/>
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="Padding" Value="0"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type GroupBox}">
          <DockPanel Background="{TemplateBinding Background}">
            <wpf:ColorZone
              x:Name="PART_ColorZone"
              DockPanel.Dock="Top"
              Padding="{TemplateBinding Padding}"
              Margin="0,0,0,-1"
              Background="{DynamicResource PrimaryHueMidLightBrush}"
              Foreground="{DynamicResource PrimaryHueMidLightForegroundBrush}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
              <ContentPresenter
                DockPanel.Dock="Top"
                ContentSource="Header"
                RecognizesAccessKey="False"
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                Margin="{TemplateBinding Padding}"
                TextBlock.FontFamily="{DynamicResource MidSubHeaderFontFamily}"
                TextBlock.FontSize="{DynamicResource GroupBoxHeaderFontSize}"
                ContentStringFormat="{TemplateBinding HeaderStringFormat}"
                ContentTemplate="{TemplateBinding HeaderTemplate}"
                ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"/>
            </wpf:ColorZone>
            <ContentPresenter
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
              Margin="{TemplateBinding Padding}"
              ContentStringFormat="{TemplateBinding ContentStringFormat}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
          </DockPanel>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="MaterialDesignFlatGroupBox" TargetType="{x:Type GroupBox}">
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"/>
    <Setter Property="BorderThickness" Value="0"/>
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="Padding" Value="0,4,0,4"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type GroupBox}">
          <DockPanel Background="{TemplateBinding Background}">
            <ContentPresenter
              DockPanel.Dock="Top"
              ContentSource="Header"
              RecognizesAccessKey="False"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
              TextBlock.FontFamily="{DynamicResource MidSubHeaderFontFamily}"
              TextBlock.FontSize="{DynamicResource GroupBoxHeaderFontSize}"
              ContentStringFormat="{TemplateBinding HeaderStringFormat}"
              ContentTemplate="{TemplateBinding HeaderTemplate}"
              ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"/>
            <ContentPresenter
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
              Margin="{TemplateBinding Padding}"
              ContentStringFormat="{TemplateBinding ContentStringFormat}"
              ContentTemplate="{TemplateBinding ContentTemplate}"
              ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"/>
          </DockPanel>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="{x:Type GroupBox}" BasedOn="{StaticResource MaterialDesignNoColorRaisedCardGroupBox}" TargetType="{x:Type GroupBox}"/>

</ResourceDictionary>
